package com.cristina.attention.pending;

import com.cristina.attention.domain.MessageInfo;
import com.cristina.attention.handler.ImHandlerHolder;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author by superman
 */
@Data
@Accessors(chain = true)
@Slf4j
public class ImTask implements Runnable{

    @Resource
    private ImHandlerHolder imHandlerHolder;

    /**
     * 用于接收批量聊天记录并保存 im业务, 批处理
     */
    private MessageInfo messageInfo;

    @Override
    public void run() {
        if (Objects.isNull(messageInfo)) {
            return;
        }
        imHandlerHolder.route(messageInfo.getSendChannel()).doHandler(messageInfo);
    }
}
